/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.securityrat.entities_temp;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author p.vivoli
 */
@Entity
@Table(name = "rel_sp", catalog = "dbrequisiti", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RelSp.findAll", query = "SELECT r FROM RelSp r"),
    @NamedQuery(name = "RelSp.findByIdSystem", query = "SELECT r FROM RelSp r WHERE r.relSpPK.idSystem = :idSystem"),
    @NamedQuery(name = "RelSp.findByIdPerimetro", query = "SELECT r FROM RelSp r WHERE r.relSpPK.idPerimetro = :idPerimetro")})
public class RelSp implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected RelSpPK relSpPK;
    @JoinColumn(name = "id_system", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private System system;
    @JoinColumn(name = "id_perimetro", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Perimetro perimetro;

    public RelSp() {
    }

    public RelSp(RelSpPK relSpPK) {
        this.relSpPK = relSpPK;
    }

    public RelSp(int idSystem, String idPerimetro) {
        this.relSpPK = new RelSpPK(idSystem, idPerimetro);
    }

    public RelSpPK getRelSpPK() {
        return relSpPK;
    }

    public void setRelSpPK(RelSpPK relSpPK) {
        this.relSpPK = relSpPK;
    }

    public System getSystem() {
        return system;
    }

    public void setSystem(System system) {
        this.system = system;
    }

    public Perimetro getPerimetro() {
        return perimetro;
    }

    public void setPerimetro(Perimetro perimetro) {
        this.perimetro = perimetro;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (relSpPK != null ? relSpPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RelSp)) {
            return false;
        }
        RelSp other = (RelSp) object;
        if ((this.relSpPK == null && other.relSpPK != null) || (this.relSpPK != null && !this.relSpPK.equals(other.relSpPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.securityrat.entities.RelSp[ relSpPK=" + relSpPK + " ]";
    }
    
}
